{include /common/header}
<script>
    var M={};
    $(function() {
        M.del = function(id){
            if (confirm('确定删除吗？')) {
                $.ajax({
                    url: '{:plugin_url('/guestbook/admin/del')}',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        id:id
                    },
                    success:function(res){
                        if (res.code) {
                            location.reload();
                        }else{
                            alert(res.message);
                        }
                    }
                });
            }
        }
    });
</script>
<div class="title">留言管理</div>
<div class="table-responsive">
    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>#</th>
                <th>联系方式</th>
                <th>称呼</th>
                <th>内容</th>
                <th>留言时间</th>
                <th>备注</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {foreach $data as $v}
            <tr>
                <td>{$v.id}</td>
                <td>{$v.contact}</td>
                <td>{$v.nickname}</td>
                <td>{$v.body}</td>
                <td>{:date('Y-m-d H:i:s', $v['create_time'])}</td>
                <td>
                    <span>{$v.remark}</span>
                    <a href="{:plugin_url('/guestbook/admin/remark')}?id={$v.id}">✍</a>
                </td>
                <td>
                    <a href="#" onclick="M.del('{$v.id}')">删除</a>
                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>
</div>
<nav>
    <ul class="pagination">
        {foreach $pages as $v}
            {if isset($v['disable'])}
                <li class="disabled"><a href="javascript:void(0);">{$v.text}</a></li>
            {elseif isset($v['current'])}
                <li class="active"><a href="javascript:void(0);">{$v.text}</a></li>
            {else}
                <li><a href="{:plugin_url('/guestbook/admin/index')}?&page={$v.page}">{$v.text}</a></li>
            {/if}
        {/foreach}
    </ul>
</nav>
<p>调用方式</p>
<pre>留言地址: <a href="{:plugin_url('/guestbook/index/index')}" target="_blank">{:plugin_url('/guestbook/index/index')}</a></pre>
{include /common/footer}